/*
 * Heap.h
 *
 *  Created on: Oct 20, 2009
 *      Author: swapnil
 */


#ifndef HEAP_H_
#define HEAP_H_

#include "../common.h"
#include "../Page.h"
#include "Heap_Common.h"
#include "../DiskSpaceManager/Database.h"

//class HFPage;
namespace HeapGUI{

int initHeap();
};

class Heap{

public:

Status status;
Database* database;

Page* getNewPage(int& retPageNum);
Page* getPage(int pageNum);
Status writePage(Page* page, int pageNum);
void exitDb();

/*
 * use to initialise db when the system boots up this will be used to initialise systable, syscolumn, indextable
 * first function to call before db starts
 * */
Status initDb(int init);
/*
 *initDb() implicitly calls initDbHeader which is the function use to initialise systable, syscolumn, indextable
 * */
Status initDbHeader();
int initFirstDpPage();  // use to create and initialise first DP page of any new Dp chain and will return the newly allocated page for the Dp
Status initDpPage();   // use to create and initialise new DP page not used till now dont touch it Atul
//create newDpPage when one Dp is full
Status checkData();
int getFirstDpNum();
// inserts a new record pointed to by recPtr with length recLen onto
// the page, returns RID of record
static time_t getTimeStamp();


PageId insertRecord(const char *recPtr,int thisFirstDpPage); /*standard    While passing data to insert,page number of first Dp page of the 
															  Dp chain(for thar particular table) should be supply to this function */
Status deleteRecord(PageId pid);/*standard*/
Status updateRecord(PageId pid,char* newValue);/*standard*/
void openScan(int firstDpPage);/*standard*/
char* getRecord(PageId pid);/*standard*/

};

#endif /* HEAP_H_ */
